<?php
include_only();

$subtitle_information = get_subtitle_info($subtitle_id);
//print_r($subtitle_information);

$original_language = get_language_by_id($subtitle_information['original_language']); 
$original_language = $original_language['name'];
$new_language = get_language_by_id($subtitle_information['language']); 
$new_language = $new_language['name'];
if($subtitle_information['is_favourite_video']=='1')
{
$video_information = get_favourite_video_information($subtitle_information['video_id']);
}
else
{
$video_information = get_video_information($subtitle_information['video_id']);
}
$video_title = $video_information['name'];
if($subtitle_information['public']=="1"){$public = "yes";}else{$public = "no";}
if($subtitle_information['request']=="1"){$request = "yes";}else{$request = "no";}


if(!empty($accept_member) and $accept_member=="yes")
{
mysql_query("UPDATE `teams` SET `state` = '1' WHERE `user_id` = '$member_id' and `subtitle_id` = '$subtitle_id' LIMIT 1 ;");
}

if(!empty($remove_member) and $remove_member=="yes")
{
mysql_query("UPDATE `teams` SET `state` = '-1' WHERE `user_id` = '$member_id' and `subtitle_id` = '$subtitle_id' LIMIT 1 ;");
}

$subtitle_info = "
<b>title: </b>".$subtitle_information['title']."<br>
<b>video: </b>".$video_title."<br>
<b>original language: </b>".$original_language."<br>
<b>new language: </b>".$new_language."<br>
<b>admin: </b>".get_user_name($subtitle_information['admin'])."<br>
<b>allow others to view subtitle: </b>".$public."<br>
<b>enable team features: </b>".$request."<br>
<b>lines count: </b>".get_subtitle_lines_count($subtitle_information['table_name'])."<br>
<b>increase replay time: </b>".$subtitle_information['increase_replay_time']." seconds<br>
";


$team_members = "
<table style='width:90%'>
<tr>
<td>#</td>
<td style='width:100%'>user</td>
<td></td>
</tr>
";

$res = mysql_query("SELECT * FROM `teams` WHERE `subtitle_id`='$subtitle_id' and `state`='1'");
$count = 0 ;
while ($row = mysql_fetch_array($res)) {
$count = $count + 1;
$member_info = get_member_info($row['user_id']);
$team_members = $team_members . "
<tr>
<td>".$count."&nbsp;</td>
<td>".$member_info['username']."</td>
<td>
<form method='get' action='index.php'>
<input type='hidden' name='page' value='subtitle_info' />
<input type='hidden' name='subtitle_id' value='".$subtitle_id."' />
<input type='hidden' name='remove_member' value='yes' />
<input type='hidden' name='member_id' value='".$row['user_id']."' />
<input type='submit' value='remove'/>
</form>
</td>
</tr>
";
}

$team_members = $team_members . "
</table>
";








$join_requests = "
<table style='width:100%'>
<tr>
<td>#</td>
<td style='width:100%;'>user</td>
<td></td>
<td></td>
</tr>";

$res = mysql_query("SELECT * FROM `teams` WHERE `subtitle_id`='$subtitle_id' and `state`='0'");
$count = 0 ;
while ($row = mysql_fetch_array($res)) {
$count = $count + 1;
$member_info = get_member_info($row['user_id']);
$join_requests = $join_requests . "
<tr>
<td>".$count."&nbsp;</td>
<td>".$member_info['username']."</td>
<td>
<form method='get' action='index.php'>
<input type='hidden' name='page' value='subtitle_info' />
<input type='hidden' name='subtitle_id' value='".$subtitle_id."' />
<input type='hidden' name='accept_member' value='yes' />
<input type='hidden' name='member_id' value='".$row['user_id']."' />
<input type='submit' value='accept'/>
</form>
</td>
<td>
<form method='get' action='index.php'>
<input type='hidden' name='page' value='subtitle_info' />
<input type='hidden' name='subtitle_id' value='".$subtitle_id."' />
<input type='hidden' name='remove_member' value='yes' />
<input type='hidden' name='member_id' value='".$row['user_id']."' />
<input type='submit' value='remove'/>
</form>
</td>
</tr>
";
}

$join_requests = $join_requests . "
</table>
";


?>